package game;

import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;

public class SkinnedBlock extends SkinnedPlatform{
	public final static long serialVersionUID = 1L;
	
	public SkinnedBlock(Level g, int x, int y, int w, int h, String s){
		try{
			level = g;
			this.x = x;
			this.y = y;
			width = w;
			height = h;
			icon = new ImageIcon(ImageIO.read(new File(s)));
		}catch (Exception e){}
	}
	
	public void removeSelfFromGame(){
		level.platforms.remove(this);
	}
	
	@Override
	public void bottomHit(GameRectangle g){
		if(g instanceof Mario){
			removeSelfFromGame();
			level.add(new BrickBreakAnimation(level, x+(width/2), y+(height/2)));
			for(Enemy e: level.enemies){
				if(e.intersects(this)){
					e.removeSelfFromGame();
				}
			}
		}
	}

}
